package src.dual_pointers;

/**
 * @author starsea
 * @date 2024-09-16 9:34
 */

public class Test17 {
    public int mySqrt(int x) {
        if (x <1) {
            return 0;
        }
        long left = 1;
        long right = x;
        while (left < right) {
            long mid = left+(right - left+1) / 2;
            if (mid * mid > x) {
                right = mid - 1;
            } else if (mid * mid <= x) {
                left = mid;
            }
        }
        return (int)left;

    }

}
